<?php

class Game extends Obj {
	protected $players = array();
	protected $turn = 0;

	public function Game() {
		parent::__construct();
	}

	/* Reset the game to initial state */
	public function reset(){}
	public function sitNo(){}

	public function registerPlayer($id) {
		if(count($this->players) < $this->sitNo()) {
			array_push($this->players, $id);
		}
	}

	public function getCurrPlayer(){
		$player = $this->players[$this->turn];
		return DB::load($player);
	}

	public function nextPlayer(){
		$this->turn++;
		if($this->turn >= count($this->players)){
			$this->turn = 0;
		}
	}

	public function run() {
		$action = Utils::get("cmd");
		$params = explode(";", Utils::get("p"));
		$this->doAction($this->getCurrPlayer(), $action, $params);
	}

}

?>